

const path = require('path');
const staticImg = path.join(__dirname, 'static');

function SensorbitUnoBlocks(Blockly) {
    var show_color = "#f59057";



    //RGB初始化端口
Blockly.Blocks.microbit_rgbcolorInit = {
    init:function(){
    this.setColour(show_color);
    this.appendDummyInput("")
     .appendField(new Blockly.FieldImage(staticImg+"/10.RGB-Module.svg", 84, 42))
       .appendField(Blockly.Msg.MICROBIT_RGBINIT)
       .appendField(Blockly.Msg.MICROBIT_RGBRED)
       .appendField(new Blockly.FieldDropdown([
        ['P1', "pin1"],
        ['P2', "pin2"],
       ]),"red")
       .appendField(Blockly.Msg.MICROBIT_RGBGREEN)
       .appendField(new Blockly.FieldDropdown([
        ['P8', "pin8"],
        ['P15', "pin15"],
       ]),"green")
       .appendField(Blockly.Msg.MICROBIT_RGBBLUE)
       .appendField(new Blockly.FieldDropdown([
        ['P0', "pin0"],
        ['P13', "pin13"],
       ]),"blue")
       this.setPreviousStatement(true, null);
       this.setNextStatement(true, null);
       this.setTooltip('');
    }
};

// //rgb
    //rgb颜色
    Blockly.Blocks.microbit_rgbcolor = {
        init:function(){
        this.setColour(show_color);
        this.appendDummyInput("")
        .appendField(new Blockly.FieldImage(staticImg+"/10.RGB-Module.svg", 84, 42))
        .appendField(Blockly.Msg.MICROBIT_RGBSMG)
        this.appendValueInput("COLOR", Number)
            // this.appendValueInput("rgbr", Number)
            .appendField(Blockly.Msg.MICROBIT_DISPLAYCOLOR)
            // this.appendValueInput("rgbg", Number)
            // .appendField(Blockly.Msg.MICROBIT_RGBG)
            // this.appendValueInput("rgbb", Number)
            // .appendField(Blockly.Msg.MICROBIT_RGBB)
        this.setPreviousStatement(true,null);
        this.setNextStatement(true,null);
        this.setTooltip('');
        }
    };

    return Blockly;
}

module.exports = SensorbitUnoBlocks;

